package com.mijie.homi.dao.topic;

import java.util.HashMap;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.mijie.core.IBatisDao;
import com.mijie.homi.common.domain.topic.RelatedTopic;

@Repository
public class RelatedTopicDao extends IBatisDao {

	public List<RelatedTopic> listRelatedTopic(int userId,int offset,int limit){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("userId", userId);
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return this.selectList("listRelatedTopic", parameter);
	}
	
	public int addRelatedTopic(RelatedTopic relate){
		return this.insert("addRelatedTopic", relate);
	}
	
	public Integer getChoicedOptionIdByUserIdAndTopicId(int userId, int topicId){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("userId", userId);
		parameter.put("topicId", topicId);
		return this.selectInteger("getChoicedOptionIdByUserIdAndTopicId", parameter);
	}
	
	public RelatedTopic getRelatedTopicByTopicId(int topicId,int userId){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("userId", userId);
		parameter.put("topicId", topicId);
		return this.selectOne("getRelatedTopicByTopicId", parameter);
	}
}
